package com.czh.springboot04.MyController;

import com.czh.springboot04.entity.ConsultLevel;
import com.czh.springboot04.service.ConsultLevelService;
import com.czh.springboot04.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/consultLevel")
public class ConsultLevelController {
    @Autowired
    ConsultLevelService consultLevelService;


    @PostMapping("/add")
    public R add(@RequestBody ConsultLevel consultLevel){
        int add = consultLevelService.add(consultLevel);
        if(add>0)
            return R.ok(consultLevel);
        return R.fail("添加失败");
    }

    @RequestMapping("/findAll")
    public R findAll(){
        return R.ok(consultLevelService.findAll());
    }

    @GetMapping("/{id}")
    public R findById(@PathVariable("id") int id){
        return R.ok(consultLevelService.findById(id));
    }


}
